// 适配代码
$(document).ready(init());
$(window).resize(init());
// window.onresize(init()
function init() {
    console.log(1);

    if ($(window).width() >= 1920) {
        $(window).width() && $('body').css('width', $(window).width()),
            $(window).height() && $('body').css('height', $(window).height());
    } else {
        $(window).width() && $('body').css('width', '1920px');
        var e = $(window).width() / 1920;
        $('body').css({
            transform: 'scale(' + e + ')',
            transformOrigin: 'left top',
            backgroundSize: '100% 100%',
            marginBottom: '-50%'
        });
    }
    $('head').append('<meta name="viewport" content="width=' + $(window).width() + '"/>');
}
// 柱状图
$(function () {
    // 征集数据
    // var 建议收纳请款
    var jiNumbe1 = [70, 85.8, 150];
    var jiNumbe2 = [83.1, 73.4, 55.1];
    var jiNumbe3 = [86.4, 65.2, 82.5];
    var jiNumbe4 = [72.4, 53.9, 39.1];
    var jiNumbe5 = [72.4, 53.9, 39.1];
    var jiNumbe6 = [72.4, 53.9, 39.1];
    // 征集1
    Zhj();

    function Zhj() {
        var option = {
            legend: {},
            tooltip: {},
            color: ['rgb(12, 64, 166)', 'rgb(213, 158, 12)', 'rgb(18, 134, 245)'],
            textStyle: {
                fontSize: 15,
                color: '#0976b1'
            },
            dataset: {
                source: [
                    ['校园建设', ...jiNumbe1],
                    ['健康管理', ...jiNumbe2],
                    ['阳光厨房', ...jiNumbe3],
                    ['社会保险', ...jiNumbe4],
                    ['医疗保障', ...jiNumbe5],
                    ['交通出行', ...jiNumbe6]
                ]
            },
            xAxis: {
                type: 'category',
                axisLabel: {
                    textStyle: {
                        color: '#fff',
                        fontSize: '15px'
                    }
                }
            },
            yAxis: {
                axisLabel: {
                    textStyle: {
                        color: '#fff'
                    }
                }
            },
            // Declare several bar series, each will be mapped
            // to a column of dataset.source by default.
            series: [{
                    type: 'bar'
                },
                {
                    type: 'bar'
                },
                {
                    type: 'bar'
                }
            ]
        };
        var zjBox = echarts.init(document.getElementById('zjBox'));
        zjBox.setOption(option);
        window.addEventListener('resize', function () {
            //适应div大小
            zjBox.resize();
        });
    }

    var option1 = {
        tooltip: {
            show: true,
            trigger: 'item',
            formatter: '{a} {d}%'
        },
        legend: {
            show: true,
            orient: 'horizontal',
            bottom: '0',
            icon: 'circle',
            textStyle: {
                color: '#fff',
                fontSize: '14px'
            }
        },
        color: ['rgb(73, 225, 236)', 'rgb(19, 108, 252)'],
        series: [{
            name: '访问来源',
            type: 'pie',
            radius: '60%',
            data: [{
                    value: 60,
                    name: '乡镇代表'
                },
                {
                    value: 40,
                    name: '区代表'
                }
            ],
            label: {
                show: false
            }
        }]
    };
    var Box1 = echarts.init(document.getElementById('cen-Box1'));
    Box1.setOption(option1);
    window.addEventListener('resize', function () {
        //适应div大小
        Box1.resize();
    });

    var option2 = {
        tooltip: {
            show: true,
            trigger: 'item',
            formatter: '{a} {d}%'
        },
        legend: {
            type: 'scroll',
            show: true,


            left: 10,
            right: 10,
            bottom: 15,


            // right: '30px',
            // left: '10',
            // top: '40',
            // width: '150px',
            // heigth: '150px',
            textStyle: {
                color: '#fff',
                fontSize: '14px'
            },
            // itemWidth: 20,
            // itemGap: 20,
            // padding: 5,
            // icon: 'circle'
        },
        color: [
            'rgb(19, 95, 95)',
            'rgb(37, 130, 138)',
            'rgb(42, 144, 149)',
            'rgb(42, 144, 149)',
            'rgb(73, 225, 236)',

            'rgb(0, 89, 131)',
            'rgb(0, 111, 219)',
            'rgb(42, 133, 214)',
            'rgb(76, 147, 211)',
            'rgb(106, 161, 205)',

            'rgb(9, 86, 218)',
            'rgb(44, 66, 211)',
            'rgb(62, 86, 210)',
            'rgb(81, 106, 207)',
            'rgb(110, 135, 214)',

            'rgb(22, 213, 182)',
            'rgb(69, 189, 206)',
            'rgb(92, 196, 207)',
            'rgb(244, 111, 168)',
            'rgb(229, 151, 79)'
        ],
        series: [{
            name: '访问来源',
            type: 'pie',
            radius: '60%',
            left: -320,
            data: [{
                    value: 60,
                    name: '百官街道'
                },
                {
                    value: 40,
                    name: '曹娥街道'
                },
                {
                    value: 60,
                    name: '东关街道'
                },
                {
                    value: 40,
                    name: '道墟街道'
                },

                {
                    value: 60,
                    name: '小越街道'
                },
                {
                    value: 40,
                    name: '梁湖街道'
                },
                {
                    value: 60,
                    name: '崧厦街道'
                },
                {
                    value: 40,
                    name: '章镇镇'
                },
                {
                    value: 60,
                    name: '丰惠镇'
                },

                {
                    value: 40,
                    name: '上浦镇'
                },
                {
                    value: 60,
                    name: '汤浦镇'
                },
                {
                    value: 40,
                    name: '永和镇'
                },
                {
                    value: 60,
                    name: '驿亭镇'
                },
                {
                    value: 40,
                    name: '谢塘镇'
                },

                {
                    value: 60,
                    name: '盖北镇'
                },
                {
                    value: 40,
                    name: '长塘镇'
                },
                {
                    value: 60,
                    name: '岭南乡'
                },
                {
                    value: 40,
                    name: '陈溪乡'
                },
                {
                    value: 60,
                    name: '下管镇'
                },
                {
                    value: 40,
                    name: '丁宅乡'
                }
            ],
            label: {
                show: false
            }
        }]
    };
    var Box2 = echarts.init(document.getElementById('cen-Box2'));
    Box2.setOption(option2);
    window.addEventListener('resize', function () {
        //适应div大小
        Box2.resize();
    });

    var option3 = {
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            itemWidth: 15,
            textStyle: {
                color: '#fff',
                fontSize: '14px'
            },
            width: 200,
            top: 15,
            right: 25,
            itemHeight: 15,
            data: ['意见数', '已反馈数'],
            right: 'right',
            orient: 'horizontal',
            icon: 'circle'
        },
        xAxis: {
            data: ['区级以上', '区级', '乡镇', '选民'],
            splitLine: {
                show: false
            },
            axisLabel: {
                textStyle: {
                    color: '#fff',
                    fontSize: '14px'
                }
            }
        },
        yAxis: {
            splitLine: {
                show: false
            },
            axisLabel: {
                textStyle: {
                    color: '#fff',
                    fontSize: '14px'
                }
            }
        },
        series: [{
                name: '意见数',
                type: 'bar',
                stack: '使用情况',
                data: [100, 120, 136, 110, 50, 20],
                itemStyle: {
                    normal: {
                        color: 'rgb(19, 108, 252)'
                    }
                }
            },
            {
                name: '已反馈数',
                type: 'bar',
                stack: '使用情况',
                data: [90, 100, 128, 105, 42, 40],
                itemStyle: {
                    normal: {
                        color: 'rgb(44, 170, 254)'
                    }
                }
            }
        ]
    };

    var Box3 = echarts.init(document.getElementById('center-bottom'));
    Box3.setOption(option3);
    window.addEventListener('resize', function () {
        //适应div大小
        Box3.resize();
    });

    var option4 = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                // 坐标轴指示器，坐标轴触发有效
                type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
            }
        },
        // color: ['#00dffd', '#00dffd', '#00dffd'],
        grid: {
            left: '3%',
            right: '4%',
            top: '20',
            containLabel: true
        },
        xAxis: [{
            type: 'category',
            data: [
                '百官街道',
                '曹娥街道',
                '东关街道',
                '道墟街道',
                '小越街道',
                '梁湖街道',
                '崧厦街道',
                '章镇镇',
                '丰惠镇',
                '上浦镇',
                '汤浦镇',
                '永和镇',
                '驿亭镇',
                '谢塘镇',
                '盖北镇',
                '长塘镇',
                '岭南乡',
                '陈溪乡',
                '下管镇',
                '丁宅乡'
            ],
            axisTick: {
                alignWithLabel: true
            },
            axisLabel: {
                interval: 0,
                rotate: 45, //倾斜度 -90 至 90 默认为0
                margin: 2,
                textStyle: {
                    // fontWeight:"bolder",
                    color: '#fff'
                }
            }
        }],
        yAxis: [{
            type: 'value',
            axisLabel: {
                textStyle: {
                    // fontWeight:"bolder",
                    color: '#fff'
                }
            }
        }],
        series: [{
            name: '直接访问',
            type: 'bar',
            barWidth: '60%',
            itemStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: 'rgb(170, 173, 242)'
                        },
                        {
                            offset: 1,
                            color: 'rgb(42, 44, 253)'
                        }
                    ])
                }
            },

            data: [120, 200, 40, 80, 70, 110, 130, 40, 59, 90, 43, 56, 89, 120, 250, 230, 270, 160, 170, 180]
        }]
    };
    var Box4 = echarts.init(document.getElementById('gzpjBox'));
    Box4.setOption(option4);
    window.addEventListener('resize', function () {
        //适应div大小
        Box4.resize();
    });
    var option5 = {
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            itemWidth: 15,
            textStyle: {
                color: '#fff'
            },
            top: 15,
            right: 25,
            itemHeight: 15,
            data: ['已建议数', '未建议数'],
            right: 'right',
            orient: 'horizontal',
            icon: 'circle'
        },
        xAxis: {
            data: [
                '儿童青少年“明眸亮睛”工程',
                '“品质教育”校园提升工程',
                '全民健身提升工程',
                '“健康上虞”提升工程',
                '文化下乡工程',
                '食品安全提升工程',
                '养老扶弱工程',
                '城镇老旧小区综合改造提升工程',
                '美丽乡村公路建设工程',
                '城市治堵系列工程'
            ],
            splitLine: {
                show: false
            },
            axisLabel: {
                interval: 0,
                rotate: 25, //倾斜度 -90 至 90 默认为0
                margin: 2,
                textStyle: {
                    // fontWeight:"bolder",
                    color: '#fff'
                }
            }
        },
        yAxis: {
            name: '代表建议数',
            splitLine: {
                show: false
            },
            axisLabel: {
                textStyle: {
                    color: '#fff'
                }
            }
        },
        series: [{
                name: '已建议数',
                type: 'bar',
                stack: '使用情况',
                data: [100, 120, 136, 110, 50, 20, 180, 160, 140, 130],
                itemStyle: {
                    normal: {
                        color: 'rgb(19, 108, 252)'
                    }
                }
            },
            {
                name: '未建议数',
                type: 'bar',
                stack: '使用情况',
                data: [90, 100, 128, 105, 42, 40, 20, 30, 40, 20],
                itemStyle: {
                    normal: {
                        color: 'rgb(44, 170, 254)'
                    }
                }
            }
        ]
    };
    var jdBox = echarts.init(document.getElementById('jdBox'));
    jdBox.setOption(option5);
    window.addEventListener('resize', function () {
        //适应div大小
        jdBox.resize();
    });
    // 项目档案点击事件
    $('.dazx-left').on('click', function () {
        // console.log(1);
        $('.mast').show();
        $('.MaskXmda').show();
    });
    // 政策档案点击事件
    $('.dazx-middle').on('click', function () {
        $('.mast').show();
        $('.MaskZzda').show();
    });
    // 人员名单
    $('.dazx-right').on('click', function () {
        console.log(1);
        $('.mast').show();
        $('.MaskRyda').show();
    });

    // 监督及意见反馈
    // $('.center-jdTop').on('click', function () {
    //     // console.log(1);
    //     $('.mast').show();
    //     $('.MaskJd').show();
    // });
    // 树
    $('.right-top-tit').on('click', function () {
        // console.log(1);
        $('.mast').show();
        $('.MaskTree').show();
    });
    // 项目评价
    $('.right-center-tit').on('click', function () {
        // console.log(1);
        $('.mast').show();
        $('.MaskxmPj').show();
    });
    // 工作评价
    $('.right-bottom-tit').on('click', function () {
        // console.log(1);
        $('.mast').show();
        $('.MaskgzPj').show();
    });
    // 意见征集盒子点击事件
    $('.llt span').on('click', function () {
        // console.log($(this));
        $(this).attr('class', 'spanActive').siblings().attr('class', '');

        // 征集1

        var NumberIndex = $(this).attr('data-index');
        if (NumberIndex === '1') {
            // console.log(1);
            jiNumbe1 = [70, 85.8, 150];
            jiNumbe2 = [83.1, 73.4, 55.1];
            jiNumbe3 = [86.4, 65.2, 82.5];
            jiNumbe4 = [72.4, 53.9, 39.1];
            jiNumbe5 = [72.4, 53.9, 39.1];
            jiNumbe6 = [72.4, 53.9, 39.1];
            Zhj();
        } else if (NumberIndex === '2') {
            jiNumbe1 = [90, 83.8, 150];
            jiNumbe2 = [83.1, 93.4, 55.1];
            jiNumbe3 = [86.4, 95.2, 82.5];
            jiNumbe4 = [72.4, 33.9, 39.1];
            jiNumbe5 = [72.4, 83.9, 39.1];
            jiNumbe6 = [72.4, 56.9, 39.1];
            Zhj();
        } else if (NumberIndex === '3') {
            jiNumbe1 = [100, 83.8, 150];
            jiNumbe2 = [100.1, 93.4, 55.1];
            jiNumbe3 = [100.4, 95.2, 82.5];
            jiNumbe4 = [100.4, 33.9, 39.1];
            jiNumbe5 = [100.4, 83.9, 39.1];
            jiNumbe6 = [100.4, 56.9, 39.1];
            Zhj();
        } else if (NumberIndex === '4') {
            jiNumbe1 = [100, 93.8, 150];
            jiNumbe2 = [100.1, 93.4, 93.1];
            jiNumbe3 = [100.4, 95.2, 93.5];
            jiNumbe4 = [100.4, 93.9, 39.1];
            jiNumbe5 = [100.4, 83.9, 93.1];
            jiNumbe6 = [100.4, 93.9, 39.1];
            Zhj();
        }
    });

    // 点击弹框事件
    $('#qunzhong').on('click', function () {
        $('.mast').show();
        $('.dialog').show();
    });
    $('.qudaibiao').on('click', function () {
        $('.mast').show();
        $('.Qudialog').show();
    });

    $('#zjdb').on('click', function () {
        $('.mast').show();
        $('.Zhdialog').show();
    });
    $('.ccccpj').on('click', function () {
        $('.mast').show();
        $('.pj').show();
    });

    // 取消事件
    $('.img-responsive').on('click', function () {
        $('.mast').hide();
        $('.dialog').hide();
        $('.Qudialog').hide();
        $('.Zhdialog').hide();
        $('.pj').hide();
        $('.MaskXmda').hide();
        $('.MaskZzda').hide();
        $('.MaskRyda').hide();
        $('.MaskJd').hide();
        $('.MaskTree').hide();
        $('.MaskxmPj').hide();
        $('.MaskgzPj').hide();
    });

    // mast取消事件
    $('.mast').on('click', function () {
        $('.mast').hide();
        $('.dialog').hide();
        $('.Qudialog').hide();
        $('.Zhdialog').hide();
        $('.pj').hide();
        $('.MaskXmda').hide();
        $('.MaskZzda').hide();
        $('.MaskRyda').hide();
        $('.MaskJd').hide();
        $('.MaskTree').hide();
        $('.MaskxmPj').hide();
        $('.MaskgzPj').hide();
    })

    // 项目档案
    // $('#xmda').on('click', function() {
    // 	$('.mast').show();
    // });
    $('.list li').on('click', function () {
        $(this).addClass('active');
        $(this).siblings().removeClass('active');

        $('.content').eq($('.list li').index(this)).addClass('active-1').siblings().removeClass('active-1');
    });

    // 票决
    $('#pjcj').liMarquee({
        direction: 'up'
    });
    $('.right-center-bottom').liMarquee({
        direction: 'up'
    });
    // 文字滚动
    $('.zjgg').liMarquee({
        direction: 'right'
    });

    // 树节点tab框
    $('.tabTitle ul li').on('click', function () {
        $(this).addClass('current');
        $(this).siblings().removeClass('current');

        $('.tabBox').eq($('.tabTitle ul li').index(this)).addClass('hide').siblings().removeClass('hide');
    });
    // 项目进程
    $('#xmjc').on('change', function (val) {
        // console.log('val', val);
        console.log($(this).val());
        if ($(this).val() === '“品质教育”校园提升工程') {
            $('.right-top-center').css('background', 'url(./img/Fson.png) no-repeat 20% center ')
            $('.right-top-center').css('background-size', '38%')
            $('.LING').html('50%')
        } else if ($(this).val() === '儿童青少年“明眸亮睛”工程') {
            $('.right-top-center').css('background', 'url(./img/tree.png) no-repeat 12% center ')
            $('.right-top-center').css('background-size', '52%')
        } else if ($(this).val() === '全民健身提升工程') {
            $('.right-top-center').css('background', 'url(./img/soootree.png) no-repeat 25% center ')
            $('.right-top-center').css('background-size', '27%')
        } else if ($(this).val() === '“健康上虞”提升工程') {
            $('.right-top-center').css('background', 'url(./img/sontree.png) no-repeat 20% center ')
            $('.right-top-center').css('background-size', '33%')
        } else if ($(this).val() === '文化下乡工程') {
            $('.right-top-center').css('background', 'url(./img/realtree.png) no-repeat 20% center ')
            $('.right-top-center').css('background-size', '33%')
        }

    })

    //点击地图出现天地图
    $('.center-ditu').on('click', function () {
        // console.log(1);
        // $('..center-ditu').css('display', 'none')
        $(this).hide()
        // $('.tdt-marker-icon').show()
    })
    $('.back').on('click', function () {
        $('.center-ditu').show()
        // $('.tdt-marker-icon').hide()
    })
});